package com.atomscat.lottery.controller.admin;

import com.atomscat.lottery.entity.db.LotteryPrizeEntity;
import com.atomscat.lottery.entity.vo.request.*;
import com.atomscat.lottery.entity.vo.response.BaseResponse;
import com.atomscat.lottery.service.LotteryPrizeService;
import com.atomscat.lottery.service.VoBaseRespTransformService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/lottery/prize")
@RequiredArgsConstructor
public class LotteryPrizeController {
    private final VoBaseRespTransformService voBaseRespTransformService;
    private final LotteryPrizeService lotteryPrizeService;

    @PostMapping("/page")
    public BaseResponse<Page<LotteryPrizeEntity>> lotteryPrizePage(@RequestBody PageLotteryPrizeRequest pageLotteryPrizeRequest) {
        return voBaseRespTransformService.transformSuccessful(lotteryPrizeService.pageLotteryPrize(pageLotteryPrizeRequest));
    }

    @PostMapping("/create")
    public BaseResponse<Boolean> createLotteryPrize(@Valid @RequestBody LotteryPrizeRequest lotteryPrizeRequest) {
        return voBaseRespTransformService.transformSuccessful(lotteryPrizeService.createLotteryPrize(lotteryPrizeRequest));
    }

    @PostMapping("/update")
    public BaseResponse<Boolean> updateLotteryPrize(@Valid @RequestBody UpdateLotteryPrizeRequest updateLotteryPrizeRequest) {
        return voBaseRespTransformService.transformSuccessful(lotteryPrizeService.updateLotteryPrize(updateLotteryPrizeRequest));
    }

}
